public enum BubbleSort implements Sort {
    INSTANCE;

    @Override
    public <E extends Comparable<E>> void sort(E[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length - i - 1; j++) {
                if (arr[j].compareTo(arr[j + 1]) > 0) {
                    SortingHelper.INSTANCE.swap(arr, j, j + 1);
                }
            }
        }
    }
   static class Solution {
        public int[] sortArray(int[] nums) {
            for(int i=0;i<nums.length;i++){
                for(int j=0;j<nums.length-1-i;j++){
                    if(nums[j]>nums[j+1]){
                        int t=nums[j];
                        nums[j]=nums[j+1];
                        nums[j+1]=t;
                    }
                }
            }
            return nums;
        }
    }

    public static void main(String[] args) {
        int[] arr = {6, 4, 2, 3, 1, 5};
        Solution solution = new Solution();
        for (int i : arr) {
            System.out.print(i+",");
        }
        solution.sortArray(arr);
        System.out.println();
        for (int i : arr) {
            System.out.print( i+",");
        }

    }
}
